<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>单位管理</title>
    <%@ include file="/WEB-INF/views/modules/commons/head.jsp" %>
    <%--多选css--%>
    <link rel="stylesheet" href="<s:url value="/assets/web/js/multiSelect/css/fselect.css"></s:url>">
    <!-- header -->
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
    <style>
        #gridTable tr td{
            text-align:center;
        }
        #gview_gridTable thead tr th .ui-jqgrid-sortable{
            text-align:center;
        }
        /*转成省略号*/
        /*.ui-jqgrid tr.jqgrow td { text-overflow : ellipsis; }*/
        .ui-jqgrid tr.jqgrow td {
            white-space: normal !important;
            height: 25px;
            line-height: 25px;
            vertical-align: text-top;

        }

        .nav {
            margin-left: 0;
        }

        #gview_gridTable .ui-jqgrid-bdiv {
            max-height: 450px;
        !important;
        }

        .nav > li > a:focus, .nav > li > a:hover {
            text-decoration: none;
            background-color: #33CCFF !important;
        }

        #main-container {
            padding: 50px 20px 0;
            position: relative;

            height: calc(100% - 71px);
            width: calc(100% - 19.5%);
            margin-left: 17.5%;
            margin-top: 60px;
        }

        .modal-dialog {
            z-index: 9999999;
        }

        @media (min-width: 768px) {
            .modal-content {
                -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, .5);
                box-shadow: 0 -2px 20px rgba(0, 0, 0, .5) !important;
            }
        }

        td {
            cursor: default;
        }

        /*个数*/
        #banjieNum {
            background-color: #d15b47 !important;
            margin: 10px 3px;
            color: #fff;
            position: absolute;
            top: -15px;
            right: -17px;
        }

        .project_detail_css {
            position: absolute;
            top: -36px;
            right: 20px;
            border: 1px solid #aaa;
            padding: 1px 5px;
        }

        .pdd {
            margin: 5px 0px;
        }

        .ppdd {
            margin: 0px;
        }
    </style>

</head>
<body class="bgcolor">
<%@ include file="/WEB-INF/views/modules/commons/nav.jsp" %>
<%@ include file="/WEB-INF/views/modules/commons/menu.jsp" %>
<!-- /section:basics/navbar.layout -->
<table></table>
<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <div class="pull-left">
                            <button class="btn btn-sm btn-info" id="query">条件搜索</button>
                            <button class="btn btn-sm btn-default" id="edit">修改单位</button>
                            <button class="btn btn-sm btn-success" id="create">添加单位</button>
                            <button class="btn btn-sm btn-danger" id="delete" style="display: none">删除单位</button>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <!-- jqGrid表格 -->
                        <table id="gridTable"></table>
                        <!-- jqGrid工具类 -->
                        <div id="gridPager"></div>
                        <!-- 查询对话框 -->
                        <div style="display: none;">
                            <div class="row" id="queryDialog"></div>
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>

    <!-- dialog -->
    <%@ include file="/WEB-INF/views/include/dialog.jsp" %>
</div><!-- /.main-container -->
</div>


<!-- footer -->
<script src="<s:url value="/assets/web/js/jquery.min.js?v=2.1.4"></s:url>"></script>
<%--公用js--%>
<script src="<s:url value="/assets/web/js/commo.js"></s:url>"></script>
<link rel="stylesheet" href="<s:url value="/assets/web/css/login/bootstrap.min.css?v=3.3.6"></s:url>">
<script src="<s:url value="/assets/web/js/jqpaginator.min.js"></s:url>"></script>
<script src="<s:url value="/assets/web/js/baseAPI.js"></s:url>"></script>
<%--多选js--%>
<script src="<s:url value="/assets/web/js/multiSelect/js/fselect.js"></s:url>"></script>
<script src="<s:url value="/assets/web/common/bootstrapvalidator/dist/js/bootstrapValidator.js"></s:url>"></script>
<%@ include file="/WEB-INF/views/include/footer.jsp" %>
<!-- dialog -->
<%@ include file="/WEB-INF/views/include/dialog.jsp" %>

<script type="text/javascript">
    //基本路径
    var baseUrl = "<s:url value="/modules/sys/Capital"></s:url>/"

    //jqgrid的表格高度
    var height = 320;
    //jqgrid表格行头的中文
    var colNames = ['', '单位名称'];
    //jqgrid表格中每一行的信息模型
    var colModel = [
        {name: 'sysId', width: 0, hidden: true, key: true},
        {name: 'name', index: 'name', width: 120, editable: true}
    ];

    //jqgrid的具体执行方法
    jqgrid({
        shrinkToFit: false,

        gridTableId: "#gridTable",
        gridPagerId: "#gridPager"
    });


    function aa10Fmatter(cellvalue, options, rowObject) {
        if (cellvalue == "1") {
            return "审核通过";
        } else if (cellvalue == "0") {
            return "未审核";
        } else if (cellvalue == "2") {
            return "作废";
        } else if (cellvalue == "3") {
            return "回退";
        }
    }

    function aa11Fmatter(cellvalue, options, rowObject) {
        if (cellvalue == "0") {
            return "否";
        } else if (cellvalue == "1") {
            return "是";
        } else {
            return "";
        }
    }


    //加载查询对话框
    $("#queryDialog").load(getUrl("filter"));

    //重置表单
    function reset() {
        resetForm("#formDialog form");
    }

    //显示查询对话框
    var queryDialog = $("#queryDialog");
    $("#query").click(function () {
        showDialog({
            dialogTitle: '查询对话框',
            dialogBody: queryDialog,
            dialogFoot: "<button type='button' class='btn btn-primary' onclick='query()'>查询</button>" +
                "<button type='button' class='btn btn-pink' onclick='reset()'>重置</button>" +
                "<button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>"
        });
    });
    var exportData = '';
    var exportDataArray = '';

    //具体查询方法
    function query() {
        exportData = $('#formDialog form').serialize();
        exportData = encodeURI(encodeURI(decodeURIComponent(exportData, true)));
        exportDataArray = $('#formDialog form').serializeArray();
        //console.log(exportData);
        seachJqgird("#gridTable", "#formDialog form");
        $("#formDialog").modal('hide');
    }

    //更新操作
    $("#edit").click(function () {
        showEditView();
    });

    //执行更新操作
    function edit() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("edit"),
            tableId: "#gridTable",
            successMessage: "更新成功",
            successTitle: '更新对话框',
            failMessage: '更新失败',
            failTitle: '消息对话框'
        });
    }

    //显示编辑对话框
    function showEditView() {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "更新对话框",
            dialogUrl: getUrl("edit"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="edit()">更新</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    }

    //显示编辑对话框
    function showView() {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "更新对话框",
            dialogUrl: getUrl("edit"),
            dialogFoot: '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    }

    //删除
    $("#delete").click(function () {
        showDeleteView();
    });

    //显示删除对话框
    function showDeleteView() {
        showDeleteDialog({
            url: getUrl("delete"),
            tableId: "#gridTable",
            confirmTitle: "确认对话框",
            confirmMessage: "是否确定删除?",
            confirmOk: "确定",
            confirmCancel: "取消",
            successMessage: "删除成功",
            successTitle: "消息对话框",
            failMessage: "删除失败",
            failTitle: "消息对话框",
            errorTitle: "警告提示框",
            errorMessage: "您当前尚未选中一行，请选择后再试",
            errorOk: "确定"
        });
    }

    //显示创建对话框
    $("#create").click(function () {
        loadDialog({
            dialogTitle: '创建对话框',
            dialogUrl: getUrl("create"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="create()">提交审核</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>'
        });
    });

    //分类编辑框
    $("#createCla").click(function () {
        loadDialog({
            dialogTitle: '创建对话框',
            dialogUrl: getUrl("createCla"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="create()">添加</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>'
        });
    });

    //保存数据
    function create() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("create"),
            tableId: "#gridTable",
            successMessage: "保存成功",
            successTitle: '保存对话框',
            //failMessage: '保存失败',
            failTitle: '消息对话框'
        });
    }


    $("#gridTable").dblclick(function (e) {
        showView();
    });

    function confirmBOX(obj) {
        if (obj.msg == undefined) {
            obj.msg = ''
        }
        bootbox.confirm({
            title: '确认提示',
            message: obj.msg,
            buttons: {
                confirm: {
                    label: '<i class="fa fa-check"></i>确认',
                    className: "btn-success btn-sm",
                },
                cancel: {
                    label: '<i class="fa fa-times"></i>取消',
                    className: "btn-sm btn-danger",
                }
            },
            callback: obj.callback
        });
    }
</script>

</body>
</html>